/**
 * <copyright>
 * </copyright>
 *

 */
package ms.unicorn.language.languagedef.impl;

import java.util.Collection;

import ms.unicorn.language.languagedef.FigureDef;
import ms.unicorn.language.languagedef.LanguagedefPackage;
import ms.unicorn.language.languagedef.SubFigure;
import ms.unicorn.language.languagedef.TagDef;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Figure Def</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ms.unicorn.language.languagedef.impl.FigureDefImpl#getClazz <em>Clazz</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.FigureDefImpl#isInherited <em>Inherited</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.FigureDefImpl#getSuperElement <em>Super Element</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.FigureDefImpl#getChildren <em>Children</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.FigureDefImpl#getTags <em>Tags</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class FigureDefImpl extends ModuleItemImpl implements FigureDef
{
  /**
   * The default value of the '{@link #getClazz() <em>Clazz</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getClazz()
   * @generated
   * @ordered
   */
  protected static final String CLAZZ_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getClazz() <em>Clazz</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getClazz()
   * @generated
   * @ordered
   */
  protected String clazz = CLAZZ_EDEFAULT;

  /**
   * The default value of the '{@link #isInherited() <em>Inherited</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isInherited()
   * @generated
   * @ordered
   */
  protected static final boolean INHERITED_EDEFAULT = false;

  /**
   * The cached value of the '{@link #isInherited() <em>Inherited</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isInherited()
   * @generated
   * @ordered
   */
  protected boolean inherited = INHERITED_EDEFAULT;

  /**
   * The cached value of the '{@link #getSuperElement() <em>Super Element</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSuperElement()
   * @generated
   * @ordered
   */
  protected FigureDef superElement;

  /**
   * The cached value of the '{@link #getChildren() <em>Children</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getChildren()
   * @generated
   * @ordered
   */
  protected EList<SubFigure> children;

  /**
   * The cached value of the '{@link #getTags() <em>Tags</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTags()
   * @generated
   * @ordered
   */
  protected EList<TagDef> tags;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected FigureDefImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return LanguagedefPackage.Literals.FIGURE_DEF;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getClazz()
  {
    return clazz;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setClazz(String newClazz)
  {
    String oldClazz = clazz;
    clazz = newClazz;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.FIGURE_DEF__CLAZZ, oldClazz, clazz));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isInherited()
  {
    return inherited;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setInherited(boolean newInherited)
  {
    boolean oldInherited = inherited;
    inherited = newInherited;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.FIGURE_DEF__INHERITED, oldInherited, inherited));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public FigureDef getSuperElement()
  {
    if (superElement != null && superElement.eIsProxy())
    {
      InternalEObject oldSuperElement = (InternalEObject)superElement;
      superElement = (FigureDef)eResolveProxy(oldSuperElement);
      if (superElement != oldSuperElement)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, LanguagedefPackage.FIGURE_DEF__SUPER_ELEMENT, oldSuperElement, superElement));
      }
    }
    return superElement;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public FigureDef basicGetSuperElement()
  {
    return superElement;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSuperElement(FigureDef newSuperElement)
  {
    FigureDef oldSuperElement = superElement;
    superElement = newSuperElement;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.FIGURE_DEF__SUPER_ELEMENT, oldSuperElement, superElement));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<SubFigure> getChildren()
  {
    if (children == null)
    {
      children = new EObjectContainmentEList<SubFigure>(SubFigure.class, this, LanguagedefPackage.FIGURE_DEF__CHILDREN);
    }
    return children;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<TagDef> getTags()
  {
    if (tags == null)
    {
      tags = new EObjectContainmentEList<TagDef>(TagDef.class, this, LanguagedefPackage.FIGURE_DEF__TAGS);
    }
    return tags;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case LanguagedefPackage.FIGURE_DEF__CHILDREN:
        return ((InternalEList<?>)getChildren()).basicRemove(otherEnd, msgs);
      case LanguagedefPackage.FIGURE_DEF__TAGS:
        return ((InternalEList<?>)getTags()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case LanguagedefPackage.FIGURE_DEF__CLAZZ:
        return getClazz();
      case LanguagedefPackage.FIGURE_DEF__INHERITED:
        return isInherited();
      case LanguagedefPackage.FIGURE_DEF__SUPER_ELEMENT:
        if (resolve) return getSuperElement();
        return basicGetSuperElement();
      case LanguagedefPackage.FIGURE_DEF__CHILDREN:
        return getChildren();
      case LanguagedefPackage.FIGURE_DEF__TAGS:
        return getTags();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case LanguagedefPackage.FIGURE_DEF__CLAZZ:
        setClazz((String)newValue);
        return;
      case LanguagedefPackage.FIGURE_DEF__INHERITED:
        setInherited((Boolean)newValue);
        return;
      case LanguagedefPackage.FIGURE_DEF__SUPER_ELEMENT:
        setSuperElement((FigureDef)newValue);
        return;
      case LanguagedefPackage.FIGURE_DEF__CHILDREN:
        getChildren().clear();
        getChildren().addAll((Collection<? extends SubFigure>)newValue);
        return;
      case LanguagedefPackage.FIGURE_DEF__TAGS:
        getTags().clear();
        getTags().addAll((Collection<? extends TagDef>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case LanguagedefPackage.FIGURE_DEF__CLAZZ:
        setClazz(CLAZZ_EDEFAULT);
        return;
      case LanguagedefPackage.FIGURE_DEF__INHERITED:
        setInherited(INHERITED_EDEFAULT);
        return;
      case LanguagedefPackage.FIGURE_DEF__SUPER_ELEMENT:
        setSuperElement((FigureDef)null);
        return;
      case LanguagedefPackage.FIGURE_DEF__CHILDREN:
        getChildren().clear();
        return;
      case LanguagedefPackage.FIGURE_DEF__TAGS:
        getTags().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case LanguagedefPackage.FIGURE_DEF__CLAZZ:
        return CLAZZ_EDEFAULT == null ? clazz != null : !CLAZZ_EDEFAULT.equals(clazz);
      case LanguagedefPackage.FIGURE_DEF__INHERITED:
        return inherited != INHERITED_EDEFAULT;
      case LanguagedefPackage.FIGURE_DEF__SUPER_ELEMENT:
        return superElement != null;
      case LanguagedefPackage.FIGURE_DEF__CHILDREN:
        return children != null && !children.isEmpty();
      case LanguagedefPackage.FIGURE_DEF__TAGS:
        return tags != null && !tags.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (clazz: ");
    result.append(clazz);
    result.append(", inherited: ");
    result.append(inherited);
    result.append(')');
    return result.toString();
  }

} //FigureDefImpl
